from multiprocessing import Pool,current_process
import time
lst = []
def task(i):
    print(current_process().name,i,"start......")
    time.sleep(2)
    lst.append(i)
    print(lst)
    print(current_process().name,i,'end......')

if __name__ == '__main__':
    p = Pool(processes=4,maxtasksperchild=3)
    for i in range(20):
        p.apply_async(func=task,args=(i,))
    p.close()
    p.join()
    print("end......")
